from rest_framework.serializers import ModelSerializer
from users.models import User


class UserViewModelSerializer(ModelSerializer):
    class Meta:
        model = User
        fields = ('id', 'username', 'email', 'mobile', 'password')

    # 重写create方法实现新增用户密码加密处理
    def create(self, validated_data):
        return User.objects.create_user(**validated_data)
